package com.itkun.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itkun.damain.Book;
import com.itkun.service.IBookService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class BookDaoTest_01 {
    @Autowired
    private IBookService bookService;
    @Test
    void testGetById(){
        System.out.println(bookService.getById(1));
    }
    @Test
    void testSave(){
        Book book = new Book();
        book.setUname("侧试数据123");
        book.setUpassword("侧试数据123");
        book.setUsex("侧试数据123");
        book.setUemail("侧试数据123");
        bookService.save(book);
    }

    @Test
    void testUpdate(){
        Book book = new Book();
        book.setUid(7);
        book.setUname("侧试数据abcdefg");
        book.setUpassword("侧试数据123");
        book.setUsex("侧试数据123");
        book.setUemail("侧试数据123");
        bookService.updateById(book);

    }

    @Test
    void testDelete(){
        bookService.removeById(5);
    }

    @Test
    void testGetAll(){  bookService.list();}

    @Test
    void testGetPage(){
        IPage<Book> page = new Page<Book>(1,2);
        bookService.page(page);
        System.out.println(page.getCurrent());
        System.out.println(page.getSize());
        System.out.println(page.getTotal());
        System.out.println(page.getPages());
        System.out.println(page.getRecords());
    }


}